{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> OTC管理
    <span class="c-gray en">&gt;</span> 出售列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="/otc/otc_sell_lists" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            <span class="select-box" style="width: 100px;">
                <select name="select_type" class="select">
                    <option value="-1">查询条件</option>
                    <option value="1" {if isset($_GET['select_type']) && $_GET['select_type'] == 1}selected{/if}>卖家订单号</option>
                    <option value="2" {if isset($_GET['select_type']) && $_GET['select_type'] == 2}selected{/if}>卖家手机号码</option>
                    <option value="3" {if isset($_GET['select_type']) && $_GET['select_type'] == 3}selected{/if}>成交订单id</option>
                    <option value="4" {if isset($_GET['select_type']) && $_GET['select_type'] == 4}selected{/if}>成交订单号</option>
                </select>
            </span>
            <input type="text" value="{:input('get.keyword')}" name="keyword" class="input-text" style="width:160px;">

            订单时间：
            <span class="select-box" style="width: 100px;">
                <select name="time_type" class="select">
                    <option value="-1">时间类型</option>
                    <option value="1" {if isset($_GET['time_type']) && $_GET['time_type'] == 1}selected{/if}>创建时间</option>
                    <option value="2" {if isset($_GET['time_type']) && $_GET['time_type'] == 2}selected{/if}>完成时间</option>
                </select>
            </span>
            <input type="text" onfocus="WdatePicker()" value="{:input('get.start')}" name="start" id="datemin" class="input-text Wdate" style="width:120px;" autocomplete="off">
            -
            <input type="text" onfocus="WdatePicker()" value="{:input('get.end')}" name="end" id="datemax" class="input-text Wdate" style="width:120px;" autocomplete="off">

            <span class="select-box" style="width: 100px;">
                <select name="status" class="select">
                    <option value="-1">全部状态</option>
                    <option value="0" {if isset($_GET['status']) && $_GET['status'] == 0}selected{/if}>下架</option>
                    <option value="1" {if isset($_GET['status']) && $_GET['status'] == 1}selected{/if}>上架</option>
                    <option value="2" {if isset($_GET['status']) && $_GET['status'] == 2}selected{/if}>已完成</option>
                    <option value="3" {if isset($_GET['status']) && $_GET['status'] == 3}selected{/if}>冻结中</option>
                    <option value="4" {if isset($_GET['status']) && $_GET['status'] == 4}selected{/if}>已取消</option>
                    <option value="5" {if isset($_GET['status']) && $_GET['status'] == 5}selected{/if}>待付款</option>
                    <option value="6" {if isset($_GET['status']) && $_GET['status'] == 6}selected{/if}>已支付/待放行</option>
                </select>
            </span>
            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l" style="color: red;">MT总出售数量：{$sell_num_sum} MT</span>
        <span class="m" style="color: red;margin-left: 230px;">MT总手续费：{$poundage_sum} MT</span>
        <span class="r">共有数据：<strong>{$page->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="12">出售列表</th>
        </tr>
        <tr class="text-c">
            <th width="35">id</th>
            <th width="100">订单号</th>
            <th width="100">卖家信息</th>
            <th width="80">出售数量</th>
            <th width="50">手续费</th>
            <th width="150">收款方式</th>
            <th width="150">成交订单信息</th>
            <th width="150">卖家备注</th>
            <th width="80">创建时间</th>
            <th width="80">完成时间</th>
            <th width="50">状态</th>
            <th width="80">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
            <td style="text-align: center">{$v.id}</td>
            <td>{$v.order_no}</td>
            <td>UID：{$v.seller_uid}</br>
                昵称：{$v.nickname}</br>
                手机：{$v.mobile}
            </td>
        <td style="text-align: center">{$v.sell_num} MT</td>
        <td style="text-align: center">{$v.poundage} MT</td>
        <td>
                {foreach $v['bank'] as $b}
                {if condition="$b['type'] eq 1"}<span style="color: #438eff">支付宝</span>:{$b['account']}{/if}
                {if condition="$b['type'] eq 2"}</br><span style="color: #22d059">微信</span>:{$b['account']}{/if}
                {if condition="$b['type'] eq 3"}</br><span style="color: #cd141a">银行卡</span>:{$b['bank_name']}{/if}
                {/foreach}
            </td>
            <td>
                成交订单id：{$v.buyers_order_id}</br>
                成交订单号：{$v.buyers_order_no}
            </td>
            <td>{$v.remark}</td>
            <td>{$v.create_time}</td>
            <td>{$v.finish_time}</td>
            <td>{switch name="$v.status"}
                {case value="0"}
                <a class="label label-danger radius" title="上架" href="javascript:;" onclick="del_otc_sell(1,{$v.id})">已下架</a>
                {/case}
                {case value="1"}
                <a class="label label-success radius" title="下架" href="javascript:;" onclick="del_otc_sell(0,{$v.id})">上架中</a>
                {/case}
                {case value="2"}已完成{/case}
                {case value="3"}<span class="label label-danger radius">已冻结</span>{/case}
                {case value="4"}<span class="label label-danger radius">已取消</span>{/case}
                {case value="5"}<span class="label label-secondary radius">待支付</span>{/case}
                {case value="6"}<span class="label label-secondary radius">已支付/待放行</span>{/case}
                {default /}--
                {/switch}</td>
            <td style="text-align: center">
                {if condition="($v.status eq 0) or ($v.status eq 1)"}
                <a class="btn btn-default radius" title="删除" href="javascript:;" onclick="del_otc_sell(2,{$v.id})">删除</a>
                {/if}
                {if condition="$v.status eq 1"}
                <a class="btn btn-default radius" title="取消" href="javascript:;" onclick="del_otc_sell(4,{$v.id})">取消</a>
                {/if}
            </td>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$page->render()|raw}
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
    //调出发货页面
    function shipments(type,id){
        layer.open({
            type: 2,
            title: '发货',
            area: ['450px', '255px'],
            fixed: false, //不固定
            maxmin: true,
            content: "shipments.html?ids="+id,
            success: function(layero, index){
                //从父页面给自页面赋值
                var jquerySendHelloButton = $('#typeid', layero.find("iframe")[0].contentWindow.document);
                jquerySendHelloButton.attr("value", type);

                var jquerySendHelloButton = $('#id', layero.find("iframe")[0].contentWindow.document);
                jquerySendHelloButton.attr("value", id);


            },
        });
    }

    /*商品上下架*/
    function del_otc_sell(type,id) {
        switch (type) {
            case 0:
                var tip = '确认要下架吗？';
                break;
            case 1:
                var tip = '确认要上架吗？';
                break;
            case 2:
                var tip = '确认要删除吗？';
                break;
            case 4:
                var tip = '确认要取消该订单吗？';
                break;
        }
        layer.confirm(tip,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('del_otc_sell')}",
                data:{'type':type,'id':id},
                dataType: 'json',
                success: function(res){
                    if(res.status == 1){
                        layer.msg(res.info,{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.reload();
                        });
                    }else{
                        layer.msg(res.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(res) {
                    console.log(res.info);
                },
            });
        });

    }
</script>
